--
-- Author: mm
-- Date: 2018-03-19 14:55:37
--
-- NewguildApplyRender 对应 Node_apply_list.csb
-- 工会成员列表render

local NewguildMemberHeadRender = import(".NewguildMemberHeadRender")

local ClassRef = app.mvc.createListViewCell(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.NewGuildApplicantNode))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end


--
function ClassRef:init(data)
    self.super.init(self, data)

    self:setContentSize(self._ui.Panel:getContentSize())

    self._memberHead = NewguildMemberHeadRender.create( self._ui.head )
    self._ui.Button_agree:addClickEventListener(function()
        self:dispatchCellEvent("applyRender_Op", { true, {self._data:getMemberId()} })
    end)
    self._ui.Button_refuse:addClickEventListener(function()
        self:dispatchCellEvent("applyRender_Op", { false, {self._data:getMemberId()} })
    end)

    self:refresh()
end

-- data = guildApplicantVo 结构
function ClassRef:refresh()
    if self._data then
        self:setVisible( true )
        local data = self._data

        self._memberHead:setData( data )

        self._ui.tips:setString( data:getInviterName() )
        self._ui.mask:setVisible( not data:isOnline() ) -- 是否在线
    else
        self:setVisible( false )
    end
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
